<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<!doctype html>
<html>

<head>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>订单状态</title>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css2/bootstrap.min.css" type="text/css"/>
  <script src="${pageContext.request.contextPath}/js2/jquery-1.11.3.min.js" type="text/javascript"></script>
  <script src="${pageContext.request.contextPath}/js2/bootstrap.min.js" type="text/javascript"></script>
  <!-- 引入自定义css文件 style.css -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css2/style.css" type="text/css"/>
  <style>
    body {
      margin-top: 20px;
      margin: 0 auto;
    }
    .carousel-inner .item img {
      width: 100%;
      height: 300px;
    }
  </style>

  <script language="javascript">
    function firm()
    {
      if (confirm("你确定要删除该订单吗"))
      {
        location.href ="${pageContext.request.contextPath}/order/deleteOrder.do?oid=${order.oid}";
      }
    }
  </script>

</head>
<body>

<jsp:include page="include/header.jsp"/>

<div class="container">
  <div class="row">
    <div style="margin:0 auto; margin-top:10px;width:950px;">
      <strong>我的订单</strong>
      <table class="table table-bordered">
        <c:forEach items="${list}" var="order">
          <tbody>
          <tr class="success">
            <th colspan="4">
              订单编号:${order.oid}
              <a href="${pageContext.request.contextPath}/order/deleteOrder.do?oid=${order.oid}">
              <input type="submit" name="Submit" value="删除订单" onclick="firm()"/>
              </a>
            </th>
            <c:if test="${order.state == 1}">
              <th>
                <a href="${pageContext.request.contextPath}/order/orderClose.?oid=${order.oid}">申请退款</a>
              </th>
            </c:if>

            <c:if test="${order.state == -1}">
              <th>
                <a href="${pageContext.request.contextPath}/kdnQuery.do"></a>
              </th>
            </c:if>

            <c:if test="${order.state == 0}">
              <th>
                <a href="${pageContext.request.contextPath}/order/orderReturn.do?oid=${order.oid}"></a>
              </th>
            </c:if>

            <c:if test="${order.state == 2}">
              <th>
                <span style="color: #8c8c8c">已退款</span>
              </th>
            </c:if>

          </tr>
          <tr class="warning">
            <th>图片</th>
            <th>商品</th>
            <th>价格</th>
            <th>数量</th>
            <th>小计</th>
          </tr>

          <c:forEach items="${order.orderItemList}" var="item">
            <tr class="active">
              <td width="60" width="40%">
                <input type="hidden" name="id" value="22">
                <img src="${pageContext.request.contextPath}/static/${item.product.image}" width="70" height="60">
              </td>
              <td width="30%">
                <a target="_blank">${item.product.pname}</a>
              </td>
              <td width="20%">
                ￥${item.product.price}
              </td>
              <td width="10%">
                  ${item.count}
              </td>
              <td width="15%">
                <span class="subtotal">￥${item.subtotal}</span>
              </td>
            </tr>
          </c:forEach>
          </tbody>
          <tr class="success">
            </th>
            <c:if test="${order.state == 0}">
              <th>
                订单状态:<span style="color: red">待付款</span>
              </th>
            </c:if>

            <c:if test="${order.state == 1}">
              <th>
                订单状态:<span style="color: green">已付款</span>
              </th>
            </c:if>

            <c:if test="${order.state == 2}">
              <th>
                订单状态:<span style="color: green">已退款</span>
              </th>
            </c:if>

            <c:if test="${order.state == -1}">
              <th>
                订单状态:<span style="color: green">已完成</span>
              </th>
            </c:if>
            <th>
            <th colspan="1"></th>

            <th>订单总价</th>
            <th>￥${order.total}
              <c:if test="${order.state == 0}">
                <a href="${pageContext.request.contextPath}/order/OrderPayment.do">付款</a>
              </c:if>
            </th>
          </tr>

          <tr>
            <th colspan="5" height="5px"></th>
          </tr>
        </c:forEach>

      </table>
    </div>
  </div>

  <nav aria-label="Page navigation" >
    <ul class="pagination" style="margin-left: 40%">
      <c:if test="${page.isFirstPage == true}">
        <li class="disabled">
          <a href="#" aria-label="Previous">
            <span aria-hidden="true">首页</span>
          </a>
        </li>
      </c:if>
      <c:if test="${page.isFirstPage != true}">
        <li>
          <a href="/order/findOrder.do?start=1&uid=${uid}" aria-label="Previous">
            <span aria-hidden="true">首页</span>
          </a>
        </li>
      </c:if>
      <c:if test="${page.isFirstPage == true}">
        <li class="disabled">
          <a href="#" aria-label="Previous">
            <span aria-hidden="true">上一页</span>
          </a>
        </li>
      </c:if>
      <c:if test="${page.isFirstPage != true}">
        <li>
          <a href="/order/findOrder.do?start=${page.prePage}&uid=${uid}" aria-label="Previous">
            <span aria-hidden="true">上一页</span>
          </a>
        </li>
      </c:if>
      <c:forEach begin="${page.navigateFirstPage}" end="${page.navigateLastPage}" var="item" step="1">
        <c:if test="${item == page.pageNum}">
          <li class="active">
            <a href="/order/findOrder.do?start=${item}&uid=${uid}">${item}</a>
          </li>
        </c:if>
        <c:if test="${item != page.pageNum}">
          <li>
            <a href="/order/findOrder.do?start=${item}&uid=${uid}">${item}</a>
          </li>
        </c:if>
      </c:forEach>
      <c:if test="${page.isLastPage == true}">
        <li class="disabled">
          <a href="#" aria-label="Next">
            <span aria-hidden="true">下一页</span>
          </a>
        </li>
      </c:if>
      <c:if test="${page.isLastPage != true}">
        <li>
          <a href="/order/findOrder.do?start=${page.nextPage}&uid=${uid}" aria-label="Next">
            <span aria-hidden="true">下一页</span>
          </a>
        </li>
      </c:if>
      <c:if test="${page.isLastPage == true}">
        <li class="disabled">
          <a href="#" aria-label="Next">
            <span aria-hidden="true">尾页</span>
          </a>
        </li>
      </c:if>
      <c:if test="${page.isLastPage != true}">
        <li>
          <a href="/order/findOrder.do?start=${page.pages}&uid=${uid}" aria-label="Next">
            <span aria-hidden="true">尾页</span>
          </a>
        </li>
      </c:if>
    </ul>
  </nav>

  <jsp:include page="include/foot.jsp"/>

</body>

</html>